const Koa = require('koa');
const app = new Koa();
const serve = require('koa-static');
const proxy = require('koa2-proxy-middleware');


const options = {
    targets: {
        // (.*) means anything
        '/one/(.*)': {
            // target: process.argv[2],
            //   target: "http://192.168.65.244:8080/",
            target: "http://zxc8836.top:8080/",
            changeOrigin: true,
        },
        '/geoserver/(.*)': {
            target: process.argv[2],
            //  target: "http://192.168.65.244:9098/",
            changeOrigin: true,
        }
    }
}
app.use(
    proxy(options)
);
app.use(serve("./"));

// log request URL:
app.use(async(ctx, next) => {
    console.log(`Process ${ctx.request.method} ${ctx.request}...`);
    await next();
});


app.listen(4000);
console.log("listening on localhost:4000")

